package easypal.brilliard.world.brilliards.logic;

import java.util.LinkedList;
import java.util.List;

public class HitRecord {
	protected List<BallColor> enteredBalls = new LinkedList<BallColor>();
	protected List<BallColor> touchedBalls = new LinkedList<BallColor>();
	
	protected boolean doesWhiteBallEnter = false;
	
	public void clear() {
		enteredBalls.clear();
		touchedBalls.clear();
		this.doesWhiteBallEnter = false;
	}
//	public void end() {
//		
//	}
	public void enter(BallColor color) {
		if (color == BallColor.white) {
			this.doesWhiteBallEnter = true;
		} else {
			synchronized (enteredBalls) {
				enteredBalls.add(color);
			}
		}
		
	}
	public void touch(BallColor color) {
		synchronized (touchedBalls) {
			touchedBalls.add(color);
		}
	}
	
	public List<BallColor> getEnteredBalls() {
		return this.enteredBalls;
	}
	public List<BallColor> getTouchedBalls() {
		return this.touchedBalls;
	}
	
	public boolean doesWhiteBallEnter() {
		return this.doesWhiteBallEnter;
	}
	
	public BallColor getFirstTouchedBall() {
		if (touchedBalls.size() > 0) {
			return touchedBalls.get(0);
		} else {
			return null;
		}
	}
}
